package com.hczt.springcloud.oauthservice.entity;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hczt.springcloud.oauthservice.entity.base.BaseEntity;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.hibernate.annotations.BatchSize;

import javax.persistence.*;
import java.util.HashSet;
import java.util.Set;

/**
 * 精诚所至，金石为开。
 * 石の上にも三年;陽気の発する所金石亦透る。
 * Faith moves mountains.
 *
 * @author marvin.ma
 * @create 2017-12-11 22:57
 * @desc ${DESCRIPTION}
 **/
@Data
@Entity
@EqualsAndHashCode(callSuper = false)
public class Role extends BaseEntity {
    private static final long serialVersionUID = -6425429113085541853L;

    @Id
    @GeneratedValue
    private Long id;
    private String name;
    private String value;

    @JsonIgnore
    @ManyToMany(targetEntity = Authority.class, fetch = FetchType.EAGER)
    @BatchSize(size = 20)
    private Set<Authority> authorities = new HashSet<>();
}
